//获取应用实例
const app = getApp()
let lazyload;
Page({
  data: {
    classNote: 'item-', 
    navData: [
      {
        name: "首页",  //文本
        current: 1,    //是否是当前页，0不是  1是
        style: 0,     //样式
        icourl: '/images/icon/ic_shouye_2.png',  //不同图标
        fn: 'gotoIndex'   //对应处理函数
      }, {
        name: "分类",
        current: 0,
        style: 0,
        icourl: '/images/icon/ic_fenlei.png',
        fn: 'gotoOldGoods'
      }, {
        name: "AI量体",
        current: 0,
        style: 1,
        icourl: '/images/icon/ic_fenlei.png',
        fn: 'gotoPublish'
      }, {
        name: "专题",
        current: 0,
        style: 0,
        icourl: '/images/icon/ic_zhuanti.png',
        fn: 'gotoRecruit'
      }, {
        name: "我的",
        current: 0,
        style: 0,
        icourl: '/images/icon/ic_wode.png',
        fn: 'gotoMine'
      },
    ],
    imgUrls: [
      '/images/banner/banner.jpg',
      '/images/banner/banner.jpg',
      '/images/banner/banner.jpg'
    ],
    imglist:[
      { img: '/images/zhanwei/yinxiang.png', text: '7秒第一印象，如何搞定洽谈定制穿搭', title:'时尚尖货'},
      { img: '/images/zhanwei/yinxiang.png', text: '7秒第一印象，如何搞定洽谈定制穿搭', title: '时尚尖货' },
      { img: '/images/zhanwei/yinxiang.png', text: '7秒第一印象，如何搞定洽谈定制穿搭', title: '时尚尖货' },
      { img: '/images/zhanwei/yinxiang.png', text: '7秒第一印象，如何搞定洽谈定制穿搭', title: '时尚尖货' },
      { img: '/images/zhanwei/yinxiang.png', text: '7秒第一印象，如何搞定洽谈定制穿搭', title: '时尚尖货' },
      { img: '/images/zhanwei/yinxiang.png', text: '7秒第一印象，如何搞定洽谈定制穿搭', title: '时尚尖货' }
    ],
    group: [
      { img: '/images/zhanwei/nvzhuang.png', show: false, def:'/images/zhanwei/yinxiang.png' },
      { img: '/images/zhanwei/nvzhuang.png', show: false, def: '/images/zhanwei/yinxiang.png' },
      { img: '/images/zhanwei/nvzhuang.png', show: false, def: '/images/zhanwei/yinxiang.png' },
 
    ],
    height:0,
    indicatorDots: true,
    autoplay: true,
    indicatorCo: "red",
    indicatoraAC: "red",
    swiperCurrent: 0,
    countDownHour: 0,
    countDownMinute: 0,
    countDownSecond: 0,
  },
  gotoOldGoods: function(){
    wx.redirectTo({
      url: '/pages/oldgoods/oldgoods',
    });
  },
  gotoPublish:function(){
    wx.redirectTo({
      url: '/pages/publish/publish',
    });
  },
  gotoRecruit:function(){
    wx.redirectTo({
      url: '/pages/recruit/recruit',
    });
  },
  gotoMine:function(){
    wx.redirectTo({
      url: '/pages/mine/mine',
    });
  },
  swiperChange(e) {
    let current = e.detail.current;
    // console.log(current, '轮播图')
    let that = this;
    that.setData({
      swiperCurrent: current,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
   
  },
  outputSrc(e) {
    // 只需查看本事件触发即可知道image 的加载情况
    console.log(e.currentTarget.dataset.src)
  },
  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    let totalSecond = 1505540080 - Date.parse(new Date())/1000;  //获取倒计时
    var interval = setInterval(function () { // 秒数 
      var second = totalSecond; // 天数位 
      var day = Math.floor(second / 3600 / 24); 
      var dayStr = day.toString(); if (dayStr.length == 1) dayStr = '0' + dayStr; // 小时位
      var hr = Math.floor((second - day * 3600 * 24) / 3600); 
      var hrStr = hr.toString(); 
      if (hrStr.length == 1) hrStr = '0' + hrStr;
       // 分钟位 
       var min = Math.floor((second - day * 3600 *24 - hr * 3600) / 60); 
       var minStr = min.toString(); if (minStr.length == 1) minStr = '0' + minStr; 
       // 秒位 
       var sec = second - day * 3600 * 24 - hr * 3600 - min*60; 
       var secStr = sec.toString(); if (secStr.length == 1) secStr = '0' + secStr; 
       this.setData({ countDownDay: dayStr, countDownHour: hrStr, countDownMinute: minStr, countDownSecond: secStr, }); 
       totalSecond--; 
       if (totalSecond < 0) { clearInterval(interval); 
       this.setData({ countDownDay: '00', countDownHour: '00', countDownMinute: '00', countDownSecond: '00', }); 
      } 
    }.bind(this), 1000);
   
  },
  showImg() {
    let group = this.data.group 
    let height = this.data.height 
    // 页面的可视高度 
    wx.createSelectorQuery().selectAll('.kuzilist').boundingClientRect((ret) => { ret.forEach((item, index) => { 
        console.log(item.top+"hefan")
        console.log(height+"mq")
        if (item.top <= height) {
          // 判断是否在显示范围内 
          group[index].show = true // 根据下标改变状态
          console.log(group[index].show);
        }
       }) 
       this.setData({ group }) }).exec()
    },
    onPageScroll:function(){
        // 滚动事件 
        this.showImg() 
      
    },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.height = app.globalData.windwHeight;
    console.log(this.height);
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  },
 
})
